<include file='Public:head' />
<body class="J_scroll_fixed">
<div class="wrap J_check_wrap">
  <div class="nav">
  <div class="return"><a href="{:U('Model/index')}">返回模型管理</a></div>  <ul class="cc">
        <li ><a href="{:U('ModelField/index',array('mid'=>$_GET['mid']))}">字段管理</a></li>
        <li class="current"><a href="javascript:;">添加字段</a></li>
        
      </ul>
</div>
  <div class="h_a">模型“{$model.remark}”，字段属性</div>
  <form name="myform" class="J_ajaxForm" action="{:U('ModelField/add')}" method="post">
  <div class="table_full">
  <table width="100%" class="table_form contentWrap">
      <tr>
        <th width="250"><strong>字段类型</strong><br /></th>
        <td><select name="show_type" id="formtype" >
        	<option value="1">文本</option>
          <option value="2">多行文本</option>
	        <option value="3">编辑器</option>
	        <option value="4">简单编辑器</option>
	        <option value="5">单选框</option>
	        <option value="6">下拉框</option>
	        <option value="7">多选框</option>
	        <option value="8">文件上传框</option>
	        <option value="9">图片上传框</option>
	        <!-- <option value="10">地区联动</option>-->
          </select></td>
      </tr>
     
      <tr>
        <th width="25%"><font color="red">*</font> <strong>字段名</strong><br />
          只能由英文字母、数字和下划线组成，并且仅能字母开头，不以下划线结尾 </th>
        <td><input type="text" name="fname" id="fname" size="20" class="input"></td>
      </tr>
      <tr>
        <th><font color="red">*</font> <strong>字段别名</strong><br />
          例如：文章标题</th>
        <td><input type="text" name="title" id="title" size="30" class="input"></td>
      </tr>
      <tr>
        <th><font color="red">*</font> <strong>字段排序</strong><br />
          只能输入数字</th>
        <td><input type="text" name="sort" id="sort" size="30" class="input" value="100"></td>
      </tr>
      
      <tr>
        <th><strong>数据校验正则</strong><br />
          系统将通过此正则校验表单提交的数据合法性，如果不想校验数据请留空</th>
        <td><input type="text" name="validate" id="validate" value="" size="40" class="input">
          <select name="pattern_select" onChange="javascript:$('#validate').val(this.value)">
            <option value="">常用正则</option>
            <option value="/^[0-9.-]+$/">数字</option>
            <option value="/^[0-9-]+$/">整数</option>
            <option value="/^[a-z]+$/i">字母</option>
            <option value="/^[0-9a-z]+$/i">数字+字母</option>
            <option value="/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/">E-mail</option>
            <option value="/^[0-9]{5,20}$/">QQ</option>
            <option value="/^http:\/\//">超级链接</option>
            <option value="/^(1)[0-9]{10}$/">手机号码</option>
            <option value="/^[0-9-]{6,13}$/">电话号码</option>
          </select></td>
      </tr>
      <tr>
        <th><strong>数据校验未通过的提示信息</strong></th>
        <td><input type="text" name="error" value="" size="50" class="input"></td>
      </tr>
      <tr>
        <th>
            <strong>是否必填</strong>
        </th>
        <td>
            <label>
                <input name='require' type="radio" value="1" > 是</label>
            &nbsp;
            <label>
                <input name='require' type="radio" value="0" checked="checked"> 否</label>
        </td>
    </tr>

    <tr>
        <th>

           <strong>是否禁用</strong>
            
        </th>
        <td>
            <label>
                <input name="is_disabled" type="radio" value="1" > 是</label>
            &nbsp;
            <label>
                <input name="is_disabled" type="radio" value="0" checked="checked" > 否</label>
        </td>
    </tr>
    <tr>
        <th>
            <strong>是否列表显示</strong>
            
        </th>
        <td>
            <label>
                <input name='show_lists' type="radio" value="1" > 是</label>
            &nbsp;
            <label>
                <input name='show_lists' type="radio" value="0" checked="checked"> 否</label>
        </td>
    </tr>
    <tr>
        <th>默认值</th>
        <td>
            <table class='single'>
                <tr>
                    <td>
                        <input type="text" name="value[]" class="input" size="50"></td>
                </tr>
            </table>

            <table class='multiple'>
                <tr>
                    <td>
                        <input type="text" name="value[]" class="input" size="50">
                        <span class='hand plus'>[+]</span>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
     
    </table>
  </div>
  <div class="btn_wrap">
      <div class="btn_wrap_pd">          

        <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">添加</button>
        <input name="mid" type="hidden" value="{$Think.get.mid}" />
      </div>
    </div>
  </form>
</div>
<script type="text/javascript" src="__ROOT__/Core/Org/common.js"></script>
<script type="text/javascript">
$(function(){
  $('[name=show_type]').change(function(){
    if($(this).val()=='5' || $(this).val()=='6' || $(this).val()=='7')
    {
      $('.single input').attr('disabled','disabled');
      $('.single').hide();
      $('.multiple input').removeAttr('disabled');
      $('.multiple').show();
    }
    else
    {
      $('.single input').removeAttr('disabled');
      $('.single').show();
      $('.multiple input').attr('disabled','disabled'); 
      $('.multiple').hide();
    }
  })
  $('[name=show_type]').trigger('change');


  $('.plus').click(function(){
      var html =  $(this).parents('tr').eq(0).clone();
      html.find('input').val('');
      html.find('span').removeClass('plus').addClass('minus').html('[-]');
      $(this).parents('table').eq(0).append(html);
  })
  $('.minus').live('click',function(){
      $(this).parents('tr').eq(0).remove();
  })
})
</script>
</body>
</html>